import 'package:film/model/film_record_model.dart';
import 'package:film/service/api_service.dart';
import 'package:get/get.dart';

class PlayRecordController extends GetxController {
  DioService dioService = new DioService();
  var lookFilmList = <FilmRecord>[].obs;

  @override
  void onInit() {
    super.onInit();
    getlookFilmList();
  }

  void getlookFilmList() async {
    final ApiResponse<List<FilmRecord>> response = await dioService.getVideoRecord(page: 1, limit: 10, look: '1');
    if (response.success) {
      lookFilmList.assignAll(response.data ?? []);
    }
  }

  /// 删除单条记录
  void removeRecord(int index) async {
    final ApiResponse<void> response = await dioService.delVideoRecord(videoId: lookFilmList[index].vodId!.toString(), look: '1');
    if (response.success) {
      lookFilmList.removeAt(index);
    }
  }
}
